package entity.lemming;


import entity.lemming.*;
import junit.framework.TestCase;

public class LemmingTest extends TestCase {

	private Lemming lemming;
	
	protected void setUp(){
		// cannont instantiate lemming type as is abstract, use walker sample 
		lemming = new Walker(0, 0);
	}
	
	protected void tearDown(){
		lemming = null;
	}
	
	public void testAlive(){
		assertEquals(lemming.isAlive(), true);
		assertTrue((lemming.isAlive() != false && lemming.saved() != true));
		
		lemming.kill();
		assertEquals(lemming.isAlive(), false);
	}
	
	public void testEnergy(){
		assertTrue(lemming.energy() >= 0 || lemming.energy() <= 100);
	}
	
	
	/** Test the move method */
	public void testMove(){
		int old_x;
		int old_y;
		for (int i = 0; i < 200; i++){
			if (Math.random() < .2){
				lemming.turnAround();
			}
			
			old_x = lemming.getX();
			old_y = lemming.getY();
			
			lemming.move();
			
			
			// Provide the assertions
			assertEquals(old_x, (lemming.getX() - lemming.getSpeed_X()));
			assertEquals(old_y, (lemming.getY() - lemming.getSpeed_Y()));
			assertTrue(lemming.getSpeed_X() <= 1 || lemming.getSpeed_X() >= -1);
			assertTrue(lemming.getSpeed_Y() <= 1 || lemming.getSpeed_Y() >= -1);
		}
	}
	
	

	
}
